package luweiteng.demoForLogin.controller;


import luweiteng.demoForLogin.entity.TestUser;
import luweiteng.demoForLogin.service.TestUserService;
import luweiteng.demoForLogin.vo.resp.BaseResp;
import luweiteng.demoForLogin.vo.resp.DocUserResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/doc")
public class TestUserLoginController {


    @Autowired
    private TestUserService testUserService;

    @RequestMapping(value = "/login" , method = RequestMethod.POST)
    public BaseResp login(@RequestBody TestUser user){
        // 写 登录逻辑
        Assert.notNull(user.getUserName(),"用户名不能为空");
        Assert.notNull(user.getPassword(),"密码不能为空");
        DocUserResp testUser = testUserService.getTestUser(user);
        return  BaseResp.success(testUser);
    }

    @RequestMapping(value = "/show",method = RequestMethod.GET)
    public BaseResp show(){
        String s = "需要拦截的链接";
        return BaseResp.success(s);
    }
}
